<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文字遮罩效果</title>
    <style>
        /* 清楚默认样式 */
        * {
            padding: 0;
            margin: 0;
            font-weight: normal;
            list-style: none;
        }

        body {
            background: linear-gradient(to right, rgb(0, 174, 255), rgb(208, 49, 230), rgb(231, 122, 94));
        }

     
        .list {
            margin: 100px auto;
            width: 900px;
            height: 800px;
            /* flex布局使得子元素水平排列 */
            display: flex;
            background-color: rgb(74, 170, 226);

        }

        .list li {
            position: relative;
            width: 245px;
            height: 370px;
            border-radius: 10px;
            /* 设置盒子外边距 */
            margin: auto 20px;
            /* 超出li盒子的内容隐藏 */
            overflow: hidden;
        }

        .list li img {
            /* 图片占满整个盒子 */
            width: 100%;
            height: 100%;
            border-radius: 10px;
            transition: 1.2s;
        }

        .content {
            position: absolute;
            top: 370px;
            left: 0;
            width: 100%;
            font: "微软雅黑"20px;
            /* 设置行高让文字垂直居中 */
            line-height: 370px;
            text-align: center;
            /* 设置遮罩层背景颜色 */
            background-color: rgb(0, 0, 0, .5);
            /* 设置文字颜色 */
            color: #fff;
        }

        /* 鼠标滑过遮罩图片显示文字内容 */
        .list li:hover .content {
            top: 0;
            transition: top ease 0.5s 0s;

        }

        /* 鼠标划过图片缩放 */
        .list li:hover img {
            transform: scale(1.2);
        }
    </style>
</head>

<body>
    <ul class="list">
      
        <li><img src="https://img1.baidu.com/it/u=269030573,2274179256&fm=253&fmt=auto&app=138&f=JPEG?w=333&h=499"
                alt="">
            <div class="content ">
                <h1>工作细胞</h1>
            </div>
        </li>

        <li><img src="https://img2.baidu.com/it/u=3233174785,2269966189&fm=253&fmt=auto&app=138&f=JPEG?w=311&h=500"
                alt="">
            <div class="content ">
                <h1>桐崎千棘</h1>
            </div>
        </li>

        <li><img src="https://img1.baidu.com/it/u=593930472,2283406547&fm=253&fmt=auto&app=120&f=PNG?w=760&h=1124"
                alt="">
            <div class="content ">
                <h1>桐崎千棘</h1>
            </div>
        </li>

        <li><img src="https://img0.baidu.com/it/u=1918633032,2366251171&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=873"
                alt="">
            <div class="content ">
                <h1>桐崎千棘</h1>
            </div>
        </li>

    </ul>
</body>

</html>